﻿using UnityEngine;
using System.Collections;
using LitJson;

public class rectData
{
    public string key;
    public Rect rect = new Rect();
    public Texture2D texture;
    private int picWidth = 1024;

    public int altasWidth = 1024;
    public int altasHeight = 1024;

    public JsonData ToJsonData()
    {
        JsonData _jd = new JsonData();
        _jd["key"] = key;
        _jd["rect"] = GetJsonData();
        return _jd;
    }

    public string GetRectData()
    {
        return rect.x / altasWidth + "," + rect.y / altasHeight + "," + rect.width / altasWidth + "," + rect.height / altasHeight;
    }

    public JsonData GetJsonData()
    {
        JsonData _jd = new JsonData();
        _jd["x"] = rect.x / 1024f;
        _jd["y"] = rect.y / 1024f;
        _jd["w"] = rect.width / 1024f;
        _jd["h"] = rect.height / 1024f;
        return _jd;
    }
}